<%@page import="com.dems.domain.Mp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.dems.dao.StudentDao"%>
<%@ page import="com.dems.domain.Student"%>
<%@ page import="com.dems.dao.RepairDao"%>
<%@ page import="com.dems.domain.Repair"%>
<%@ page import="java.util.List" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/information.css"/>
<title>处理维修信息</title>
</head>
<body>
	<table border="4px">
		<caption class="title">处理维修信息</caption>
        <tbody>
       		<tr>
           		<th>学生姓名</th>
           		<th>学生宿舍号</th>
           		<th>学生手机号</th>
                <th>维修描述</th>
                <th>维修类型</th>
                <th>维修状态</th>
                <th>维修工人姓名</th>
                <th>维修工人手机号</th>
                <th>维修接单</th>
                <th>维修结果</th>
            </tr>
        <%
        Mp mp = (Mp)request.getSession().getAttribute("mp");
        String buildingId = mp.getBuildingId();
        String repairType = mp.getMpType();
        Repair repair = new Repair();
        RepairDao repairDao = new RepairDao();
        List<Repair> repairs = repairDao.selectRepairBybuildingId(buildingId,repairType);
        for(Repair r : repairs){
        	%>
        	<tr>
                <td><%=r.getStudentName() %></td>
                <td><%=r.getStudentDormitory() %></td>
                <td><%=r.getStudentPhone() %></td>
                <td><%=r.getRepairDescription() %></td>
                <td><%=r.getRepairType() %></td>
                <td><%=r.getRepairState() %></td>
                <td><%=r.getMpName() %></td>
                <td><%=r.getMpPhone() %></td>
                <%if(r.getRepairState().equals("等待维修") || r.getRepairState().equals("维修失败")){%>
                <td>
                	<form action="<%=request.getContextPath() %>/MpRepairResultServlet">
                		<input type="hidden" name="repairId" value="<%=r.getRepairId() %>"/>
                		<button name="button" type="submit" value="toRepair">维修接单</button>
                	</form>
                </td>
                <%}else{ %>
                <td></td>
                <%} %>
                
                <%if(r.getRepairState().equals("正在维修")){%>
                <td>
                	<form action="<%=request.getContextPath() %>/MpRepairResultServlet">
                		<input type="hidden" name="repairId" value="<%=r.getRepairId() %>"/>
                		<button name="button" type="submit" value="complete">维修完成</button>
                	</form>
                </td>
                <%}else{ %>
                <td></td>
                <%} %>
            </tr>
            
         <%} %>
         </tbody>
	</table>
</body>
</html>